<script setup lang='ts'>
defineOptions({ name: 'AppPromotions' })

const { isMobile } = storeToRefs(useWindowStore())
const appStore = useAppStore()
const { isLogin } = storeToRefs(appStore)
const { openActivity } = useActivityMenu()
definePageMeta({
    layout: 'header-back',
    title: 'promotional_activities'
  })
const currentCategoryId = ref('')

const {
  data: dataPromoList,
  loading: loadPromoList,
  runAsync: runAsyncPromoList,
  mutate,
} = useRequest(ApiMemberPromoList, {
  onSuccess(data) {
    dataPromoList.value = data
    mutate(data.filter((item) => {
      return item.images
    }).filter((item) => {
      if (item.display_mode === 1 && !isLogin.value)
        return false
      if (item.display_mode === 3)
        return false
      return true
    }))
  },
})
runAsyncPromoList({ category: '0', cate_id: currentCategoryId.value })
</script>

<template>
<div class="py-4 px-[.875rem]">
    <div class="grid grid-cols-1  gap-y-4 @lg:grid-cols-3 @sm:grid-cols-2">
      <div v-for="item of dataPromoList" :key="item.id" class="cursor-pointer" @click="openActivity(item, 1)">
            <BaseImage loading="eager" width="100%" is-network :url="item.images" />
      </div>
    </div>
</div>
</template>

<style lang='scss' scoped>

</style>
